<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- | Utilities related to Monad and Applicative classes</span><span>
</span><span id="line-2"></span><span class="hs-comment">--   Mostly for backwards compatibility.</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Utils.Monad</span><span>
</span><span id="line-5"></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier">Applicative</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-6"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator">(&lt;$&gt;)</span></a></span><span>
</span><span id="line-7"></span><span>
</span><span id="line-8"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#MonadFix"><span class="hs-identifier">MonadFix</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-9"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#MonadIO"><span class="hs-identifier">MonadIO</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-identifier">zipWith3M</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M_"><span class="hs-identifier">zipWith3M_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith4M"><span class="hs-identifier">zipWith4M</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-identifier">zipWithAndUnzipM</span></a></span><span>
</span><span id="line-12"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#mapAndUnzipM"><span class="hs-identifier">mapAndUnzipM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier">mapAndUnzip3M</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip4M"><span class="hs-identifier">mapAndUnzip4M</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip5M"><span class="hs-identifier">mapAndUnzip5M</span></a></span><span>
</span><span id="line-13"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier">mapAccumLM</span></a></span><span>
</span><span id="line-14"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapSndM"><span class="hs-identifier">mapSndM</span></a></span><span>
</span><span id="line-15"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier">concatMapM</span></a></span><span>
</span><span id="line-16"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapMaybeM"><span class="hs-identifier">mapMaybeM</span></a></span><span>
</span><span id="line-17"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#fmapMaybeM"><span class="hs-identifier">fmapMaybeM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#fmapEitherM"><span class="hs-identifier">fmapEitherM</span></a></span><span>
</span><span id="line-18"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#anyM"><span class="hs-identifier">anyM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#allM"><span class="hs-identifier">allM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#orM"><span class="hs-identifier">orM</span></a></span><span>
</span><span id="line-19"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#foldlM_"><span class="hs-identifier">foldlM_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldrM"><span class="hs-identifier">foldrM</span></a></span><span>
</span><span id="line-20"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#maybeMapM"><span class="hs-identifier">maybeMapM</span></a></span><span>
</span><span id="line-21"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#whenM"><span class="hs-identifier">whenM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#unlessM"><span class="hs-identifier">unlessM</span></a></span><span>
</span><span id="line-22"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#filterOutM"><span class="hs-identifier">filterOutM</span></a></span><span>
</span><span id="line-23"></span><span>        </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- Imports</span><span>
</span><span id="line-27"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.Fix.html#"><span class="hs-identifier">Control.Monad.Fix</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.IO.Class.html#"><span class="hs-identifier">Control.Monad.IO.Class</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#sequenceA_"><span class="hs-identifier">sequenceA_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier">foldlM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldrM"><span class="hs-identifier">foldrM</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.OldList.html#unzip4"><span class="hs-identifier">unzip4</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#unzip5"><span class="hs-identifier">unzip5</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#zipWith4"><span class="hs-identifier">zipWith4</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- Common functions</span><span>
</span><span id="line-40"></span><span class="hs-comment">--  These are used throughout the compiler</span><span>
</span><span id="line-41"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span class="hs-comment">{-

Note [Inline @zipWithNM@ functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The inline principle for 'zipWith3M', 'zipWith4M' and 'zipWith3M_' is the same
as for 'zipWithM' and 'zipWithM_' in &quot;Control.Monad&quot;, see
Note [Fusion for zipN/zipWithN] in GHC/List.hs for more details.

The 'zipWithM'/'zipWithM_' functions are inlined so that the `zipWith` and
`sequenceA` functions with which they are defined have an opportunity to fuse.

Furthermore, 'zipWith3M'/'zipWith4M' and 'zipWith3M_' have been explicitly
rewritten in a non-recursive way similarly to 'zipWithM'/'zipWithM_', and for
more than just uniformity: after [D5241](https://phabricator.haskell.org/D5241)
for issue #14037, all @zipN@/@zipWithN@ functions fuse, meaning
'zipWith3M'/'zipWIth4M' and 'zipWith3M_'@ now behave like 'zipWithM' and
'zipWithM_', respectively, with regards to fusion.

As such, since there are not any differences between 2-ary 'zipWithM'/
'zipWithM_' and their n-ary counterparts below aside from the number of
arguments, the `INLINE` pragma should be replicated in the @zipWithNM@
functions below as well.

-}</span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span id="local-6989586621680778476"><span id="local-6989586621680778477"><span id="local-6989586621680778478"><span id="local-6989586621680778479"><span id="local-6989586621680778480"><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-identifier hs-type">zipWith3M</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778480"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778479"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778478"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778477"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778480"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778476"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778479"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778478"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778477"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778480"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778476"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span></span></span></span></span></span><span>
</span><span id="line-70"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-pragma hs-type">zipWith3M</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- Inline so that fusion with 'zipWith3' and 'sequenceA' has a chance to fire.</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- See Note [Inline @zipWithNM@ functions] above.</span><span>
</span><span id="line-73"></span><span id="zipWith3M"><span class="annot"><span class="annottext">zipWith3M :: forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; m [d]
</span><a href="GHC.Utils.Monad.html#zipWith3M"><span class="hs-identifier hs-var hs-var">zipWith3M</span></a></span></span><span> </span><span id="local-6989586621680778225"><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; m d
</span><a href="#local-6989586621680778225"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778224"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778224"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621680778223"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778223"><span class="hs-identifier hs-var">ys</span></a></span></span><span> </span><span id="local-6989586621680778222"><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778222"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[m d] -&gt; m [d]
forall (t :: * -&gt; *) (f :: * -&gt; *) a.
(Traversable t, Applicative f) =&gt;
t (f a) -&gt; f (t a)
</span><a href="../../base/src/Data.Traversable.html#sequenceA"><span class="hs-identifier hs-var">sequenceA</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [m d]
forall a b c d. (a -&gt; b -&gt; c -&gt; d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d]
</span><a href="../../base/src/GHC.List.html#zipWith3"><span class="hs-identifier hs-var">zipWith3</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; m d
</span><a href="#local-6989586621680778225"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778224"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778223"><span class="hs-identifier hs-var">ys</span></a></span><span> </span><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778222"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span id="local-6989586621680778458"><span id="local-6989586621680778459"><span id="local-6989586621680778460"><span id="local-6989586621680778461"><span id="local-6989586621680778462"><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M_"><span class="hs-identifier hs-type">zipWith3M_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778462"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778461"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778460"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778459"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778462"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778458"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778461"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778460"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778459"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778462"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span></span></span></span><span>
</span><span id="line-76"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith3M_"><span class="hs-pragma hs-type">zipWith3M_</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- Inline so that fusion with 'zipWith4' and 'sequenceA' has a chance to fire.</span><span>
</span><span id="line-78"></span><span class="hs-comment">-- See  Note [Inline @zipWithNM@ functions] above.</span><span>
</span><span id="line-79"></span><span id="zipWith3M_"><span class="annot"><span class="annottext">zipWith3M_ :: forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; m ()
</span><a href="GHC.Utils.Monad.html#zipWith3M_"><span class="hs-identifier hs-var hs-var">zipWith3M_</span></a></span></span><span> </span><span id="local-6989586621680778214"><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; m d
</span><a href="#local-6989586621680778214"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778213"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778213"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621680778212"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778212"><span class="hs-identifier hs-var">ys</span></a></span></span><span> </span><span id="local-6989586621680778211"><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778211"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[m d] -&gt; m ()
forall (t :: * -&gt; *) (f :: * -&gt; *) a.
(Foldable t, Applicative f) =&gt;
t (f a) -&gt; f ()
</span><a href="../../base/src/Data.Foldable.html#sequenceA_"><span class="hs-identifier hs-var">sequenceA_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c -&gt; m d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [m d]
forall a b c d. (a -&gt; b -&gt; c -&gt; d) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d]
</span><a href="../../base/src/GHC.List.html#zipWith3"><span class="hs-identifier hs-var">zipWith3</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; m d
</span><a href="#local-6989586621680778214"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778213"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778212"><span class="hs-identifier hs-var">ys</span></a></span><span> </span><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778211"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span id="local-6989586621680778444"><span id="local-6989586621680778445"><span id="local-6989586621680778446"><span id="local-6989586621680778447"><span id="local-6989586621680778448"><span id="local-6989586621680778449"><span class="annot"><a href="GHC.Utils.Monad.html#zipWith4M"><span class="hs-identifier hs-type">zipWith4M</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778449"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778448"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778447"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778446"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778445"><span class="hs-identifier hs-type">d</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778449"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778444"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778448"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778447"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778446"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778445"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778449"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778444"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">]</span></span></span></span></span></span></span><span>
</span><span id="line-83"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWith4M"><span class="hs-pragma hs-type">zipWith4M</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- Inline so that fusion with 'zipWith5' and 'sequenceA' has a chance to fire.</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- See  Note [Inline @zipWithNM@ functions] above.</span><span>
</span><span id="line-86"></span><span id="zipWith4M"><span class="annot"><span class="annottext">zipWith4M :: forall (m :: * -&gt; *) a b c d e.
Monad m =&gt;
(a -&gt; b -&gt; c -&gt; d -&gt; m e) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d] -&gt; m [e]
</span><a href="GHC.Utils.Monad.html#zipWith4M"><span class="hs-identifier hs-var hs-var">zipWith4M</span></a></span></span><span> </span><span id="local-6989586621680778206"><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; d -&gt; m e
</span><a href="#local-6989586621680778206"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778205"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778205"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621680778204"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778204"><span class="hs-identifier hs-var">ys</span></a></span></span><span> </span><span id="local-6989586621680778203"><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778203"><span class="hs-identifier hs-var">ws</span></a></span></span><span> </span><span id="local-6989586621680778202"><span class="annot"><span class="annottext">[d]
</span><a href="#local-6989586621680778202"><span class="hs-identifier hs-var">zs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[m e] -&gt; m [e]
forall (t :: * -&gt; *) (f :: * -&gt; *) a.
(Traversable t, Applicative f) =&gt;
t (f a) -&gt; f (t a)
</span><a href="../../base/src/Data.Traversable.html#sequenceA"><span class="hs-identifier hs-var">sequenceA</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c -&gt; d -&gt; m e) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d] -&gt; [m e]
forall a b c d e.
(a -&gt; b -&gt; c -&gt; d -&gt; e) -&gt; [a] -&gt; [b] -&gt; [c] -&gt; [d] -&gt; [e]
</span><a href="../../base/src/Data.OldList.html#zipWith4"><span class="hs-identifier hs-var">zipWith4</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; c -&gt; d -&gt; m e
</span><a href="#local-6989586621680778206"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778205"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778204"><span class="hs-identifier hs-var">ys</span></a></span><span> </span><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778203"><span class="hs-identifier hs-var">ws</span></a></span><span> </span><span class="annot"><span class="annottext">[d]
</span><a href="#local-6989586621680778202"><span class="hs-identifier hs-var">zs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span id="local-6989586621680778428"><span id="local-6989586621680778429"><span id="local-6989586621680778430"><span id="local-6989586621680778431"><span id="local-6989586621680778432"><span class="annot"><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-identifier hs-type">zipWithAndUnzipM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778432"><span class="hs-identifier hs-type">m</span></a></span><span>
</span><span id="line-89"></span><span>                 </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778431"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778430"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778432"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778429"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680778428"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778431"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778430"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778432"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778429"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778428"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span></span></span></span><span>
</span><span id="line-90"></span><span class="hs-pragma">{-# INLINABLE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-pragma hs-type">zipWithAndUnzipM</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- See Note [flatten_args performance] in GHC.Tc.Solver.Flatten for why this</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- pragma is essential.</span><span>
</span><span id="line-93"></span><span id="zipWithAndUnzipM"><span class="annot"><span class="annottext">zipWithAndUnzipM :: forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; m (c, d)) -&gt; [a] -&gt; [b] -&gt; m ([c], [d])
</span><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-identifier hs-var hs-var">zipWithAndUnzipM</span></a></span></span><span> </span><span id="local-6989586621680778195"><span class="annot"><span class="annottext">a -&gt; b -&gt; m (c, d)
</span><a href="#local-6989586621680778195"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778194"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778194"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778193"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778193"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778192"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680778192"><span class="hs-identifier hs-var">y</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778191"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778191"><span class="hs-identifier hs-var">ys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778190"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778190"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680778189"><span class="annot"><span class="annottext">d
</span><a href="#local-6989586621680778189"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; m (c, d)
</span><a href="#local-6989586621680778195"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778194"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680778192"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-95"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778188"><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778188"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680778187"><span class="annot"><span class="annottext">[d]
</span><a href="#local-6989586621680778187"><span class="hs-identifier hs-var">ds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; m (c, d)) -&gt; [a] -&gt; [b] -&gt; m ([c], [d])
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; b -&gt; m (c, d)) -&gt; [a] -&gt; [b] -&gt; m ([c], [d])
</span><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-identifier hs-var">zipWithAndUnzipM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; m (c, d)
</span><a href="#local-6989586621680778195"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778193"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621680778191"><span class="hs-identifier hs-var">ys</span></a></span><span>
</span><span id="line-96"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([c], [d]) -&gt; m ([c], [d])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778190"><span class="hs-identifier hs-var">c</span></a></span><span class="annot"><span class="annottext">c -&gt; [c] -&gt; [c]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[c]
</span><a href="#local-6989586621680778188"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">d
</span><a href="#local-6989586621680778189"><span class="hs-identifier hs-var">d</span></a></span><span class="annot"><span class="annottext">d -&gt; [d] -&gt; [d]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[d]
</span><a href="#local-6989586621680778187"><span class="hs-identifier hs-var">ds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-97"></span><span class="annot"><a href="GHC.Utils.Monad.html#zipWithAndUnzipM"><span class="hs-identifier hs-var">zipWithAndUnzipM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; m (c, d)
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[b]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([c], [d]) -&gt; m ([c], [d])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">{-

Note [Inline @mapAndUnzipNM@ functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The inline principle is the same as 'mapAndUnzipM' in &quot;Control.Monad&quot;.
The 'mapAndUnzipM' function is inlined so that the `unzip` and `traverse`
functions with which it is defined have an opportunity to fuse, see
Note [Inline @unzipN@ functions] in Data/OldList.hs for more details.

Furthermore, the @mapAndUnzipNM@ functions have been explicitly rewritten in a
non-recursive way similarly to 'mapAndUnzipM', and for more than just
uniformity: after [D5249](https://phabricator.haskell.org/D5249) for Trac
ticket #14037, all @unzipN@ functions fuse, meaning 'mapAndUnzip3M',
'mapAndUnzip4M' and 'mapAndUnzip5M' now behave like 'mapAndUnzipM' with regards
to fusion.

As such, since there are not any differences between 2-ary 'mapAndUnzipM' and
its n-ary counterparts below aside from the number of arguments, the `INLINE`
pragma should be replicated in the @mapAndUnzipNM@ functions below as well.

-}</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-comment">-- | mapAndUnzipM for triples</span><span>
</span><span id="line-123"></span><span id="local-6989586621680778416"><span id="local-6989586621680778417"><span id="local-6989586621680778418"><span id="local-6989586621680778419"><span id="local-6989586621680778420"><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier hs-type">mapAndUnzip3M</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778420"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778419"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778420"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778418"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778417"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778416"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778419"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778420"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778418"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778417"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778416"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span></span></span></span><span>
</span><span id="line-124"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-pragma hs-type">mapAndUnzip3M</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-125"></span><span class="hs-comment">-- Inline so that fusion with 'unzip3' and 'traverse' has a chance to fire.</span><span>
</span><span id="line-126"></span><span class="hs-comment">-- See Note [Inline @mapAndUnzipNM@ functions] above.</span><span>
</span><span id="line-127"></span><span id="mapAndUnzip3M"><span class="annot"><span class="annottext">mapAndUnzip3M :: forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; m (b, c, d)) -&gt; [a] -&gt; m ([b], [c], [d])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier hs-var hs-var">mapAndUnzip3M</span></a></span></span><span> </span><span id="local-6989586621680778179"><span class="annot"><span class="annottext">a -&gt; m (b, c, d)
</span><a href="#local-6989586621680778179"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778178"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778178"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[(b, c, d)] -&gt; ([b], [c], [d])
forall a b c. [(a, b, c)] -&gt; ([a], [b], [c])
</span><a href="../../base/src/GHC.List.html#unzip3"><span class="hs-identifier hs-var">unzip3</span></a></span><span> </span><span class="annot"><span class="annottext">([(b, c, d)] -&gt; ([b], [c], [d]))
-&gt; m [(b, c, d)] -&gt; m ([b], [c], [d])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; m (b, c, d)) -&gt; [a] -&gt; m [(b, c, d)]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m (b, c, d)
</span><a href="#local-6989586621680778179"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778178"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span id="local-6989586621680778395"><span id="local-6989586621680778396"><span id="local-6989586621680778397"><span id="local-6989586621680778398"><span id="local-6989586621680778399"><span id="local-6989586621680778400"><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip4M"><span class="hs-identifier hs-type">mapAndUnzip4M</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778400"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778399"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778400"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778398"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778397"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778396"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778395"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778399"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778400"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778398"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778397"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778396"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778395"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span></span></span></span></span><span>
</span><span id="line-130"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip4M"><span class="hs-pragma hs-type">mapAndUnzip4M</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- Inline so that fusion with 'unzip4' and 'traverse' has a chance to fire.</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- See Note [Inline @mapAndUnzipNM@ functions] above.</span><span>
</span><span id="line-133"></span><span id="mapAndUnzip4M"><span class="annot"><span class="annottext">mapAndUnzip4M :: forall (m :: * -&gt; *) a b c d e.
Monad m =&gt;
(a -&gt; m (b, c, d, e)) -&gt; [a] -&gt; m ([b], [c], [d], [e])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip4M"><span class="hs-identifier hs-var hs-var">mapAndUnzip4M</span></a></span></span><span> </span><span id="local-6989586621680778169"><span class="annot"><span class="annottext">a -&gt; m (b, c, d, e)
</span><a href="#local-6989586621680778169"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778168"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778168"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[(b, c, d, e)] -&gt; ([b], [c], [d], [e])
forall a b c d. [(a, b, c, d)] -&gt; ([a], [b], [c], [d])
</span><a href="../../base/src/Data.OldList.html#unzip4"><span class="hs-identifier hs-var">unzip4</span></a></span><span> </span><span class="annot"><span class="annottext">([(b, c, d, e)] -&gt; ([b], [c], [d], [e]))
-&gt; m [(b, c, d, e)] -&gt; m ([b], [c], [d], [e])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; m (b, c, d, e)) -&gt; [a] -&gt; m [(b, c, d, e)]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m (b, c, d, e)
</span><a href="#local-6989586621680778169"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778168"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span id="local-6989586621680778378"><span id="local-6989586621680778379"><span id="local-6989586621680778380"><span id="local-6989586621680778381"><span id="local-6989586621680778382"><span id="local-6989586621680778383"><span id="local-6989586621680778384"><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip5M"><span class="hs-identifier hs-type">mapAndUnzip5M</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778384"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778383"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778384"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778382"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778381"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778380"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778379"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778378"><span class="hs-identifier hs-type">f</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778383"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778384"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778382"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778381"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778380"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778379"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778378"><span class="hs-identifier hs-type">f</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span></span></span></span></span></span><span>
</span><span id="line-136"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.html#mapAndUnzip5M"><span class="hs-pragma hs-type">mapAndUnzip5M</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- Inline so that fusion with 'unzip5' and 'traverse' has a chance to fire.</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- See Note [Inline @mapAndUnzipNM@ functions] above.</span><span>
</span><span id="line-139"></span><span id="mapAndUnzip5M"><span class="annot"><span class="annottext">mapAndUnzip5M :: forall (m :: * -&gt; *) a b c d e f.
Monad m =&gt;
(a -&gt; m (b, c, d, e, f)) -&gt; [a] -&gt; m ([b], [c], [d], [e], [f])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip5M"><span class="hs-identifier hs-var hs-var">mapAndUnzip5M</span></a></span></span><span> </span><span id="local-6989586621680778161"><span class="annot"><span class="annottext">a -&gt; m (b, c, d, e, f)
</span><a href="#local-6989586621680778161"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778160"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778160"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">[(b, c, d, e, f)] -&gt; ([b], [c], [d], [e], [f])
forall a b c d e. [(a, b, c, d, e)] -&gt; ([a], [b], [c], [d], [e])
</span><a href="../../base/src/Data.OldList.html#unzip5"><span class="hs-identifier hs-var">unzip5</span></a></span><span> </span><span class="annot"><span class="annottext">([(b, c, d, e, f)] -&gt; ([b], [c], [d], [e], [f]))
-&gt; m [(b, c, d, e, f)] -&gt; m ([b], [c], [d], [e], [f])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/Data.Functor.html#%3C%24%3E"><span class="hs-operator hs-var">&lt;$&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; m (b, c, d, e, f)) -&gt; [a] -&gt; m [(b, c, d, e, f)]
forall (t :: * -&gt; *) (f :: * -&gt; *) a b.
(Traversable t, Applicative f) =&gt;
(a -&gt; f b) -&gt; t a -&gt; f (t b)
</span><a href="../../base/src/Data.Traversable.html#traverse"><span class="hs-identifier hs-var">traverse</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m (b, c, d, e, f)
</span><a href="#local-6989586621680778161"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778160"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span class="hs-comment">-- TODO: mapAccumLM is used in many places. Surely most of</span><span>
</span><span id="line-142"></span><span class="hs-comment">-- these don't actually want to be lazy. We should add a strict</span><span>
</span><span id="line-143"></span><span class="hs-comment">-- variant and use it where appropriate.</span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span class="hs-comment">-- | Monadic version of mapAccumL</span><span>
</span><span id="line-146"></span><span id="local-6989586621680778362"><span id="local-6989586621680778363"><span id="local-6989586621680778364"><span id="local-6989586621680778365"><span class="annot"><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-type">mapAccumLM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778365"><span class="hs-identifier hs-type">m</span></a></span><span>
</span><span id="line-147"></span><span>            </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778364"><span class="hs-identifier hs-type">acc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778363"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778365"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778364"><span class="hs-identifier hs-type">acc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680778362"><span class="hs-identifier hs-type">y</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ combining function</span><span>
</span><span id="line-148"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778364"><span class="hs-identifier hs-type">acc</span></a></span><span>                      </span><span class="hs-comment">-- ^ initial state</span><span>
</span><span id="line-149"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778363"><span class="hs-identifier hs-type">x</span></a></span><span class="hs-special">]</span><span>                      </span><span class="hs-comment">-- ^ inputs</span><span>
</span><span id="line-150"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778365"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778364"><span class="hs-identifier hs-type">acc</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778362"><span class="hs-identifier hs-type">y</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span></span></span></span></span><span>             </span><span class="hs-comment">-- ^ final state, outputs</span><span>
</span><span id="line-151"></span><span id="mapAccumLM"><span class="annot"><span class="annottext">mapAccumLM :: forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var hs-var">mapAccumLM</span></a></span></span><span> </span><span id="local-6989586621680778158"><span class="annot"><span class="annottext">acc -&gt; x -&gt; m (acc, y)
</span><a href="#local-6989586621680778158"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778157"><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778157"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621680778156"><span class="annot"><span class="annottext">[x]
</span><a href="#local-6989586621680778156"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-152"></span><span>  </span><span class="annot"><span class="annottext">acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="#local-6989586621680778155"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778157"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">[x]
</span><a href="#local-6989586621680778156"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-153"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-154"></span><span>    </span><span id="local-6989586621680778155"><span class="annot"><span class="annottext">go :: acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="#local-6989586621680778155"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680778150"><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778150"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778149"><span class="annot"><span class="annottext">x
</span><a href="#local-6989586621680778149"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778148"><span class="annot"><span class="annottext">[x]
</span><a href="#local-6989586621680778148"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-155"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680778147"><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778147"><span class="hs-identifier hs-var">s1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680778146"><span class="annot"><span class="annottext">y
</span><a href="#local-6989586621680778146"><span class="hs-identifier hs-var">x'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">acc -&gt; x -&gt; m (acc, y)
</span><a href="#local-6989586621680778158"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778150"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">x
</span><a href="#local-6989586621680778149"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-156"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621680778145"><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778145"><span class="hs-identifier hs-var">s2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680778144"><span class="annot"><span class="annottext">[y]
</span><a href="#local-6989586621680778144"><span class="hs-identifier hs-var">xs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="#local-6989586621680778155"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778147"><span class="hs-identifier hs-var">s1</span></a></span><span> </span><span class="annot"><span class="annottext">[x]
</span><a href="#local-6989586621680778148"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-157"></span><span>      </span><span class="annot"><span class="annottext">(acc, [y]) -&gt; m (acc, [y])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778145"><span class="hs-identifier hs-var">s2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">y
</span><a href="#local-6989586621680778146"><span class="hs-identifier hs-var">x'</span></a></span><span> </span><span class="annot"><span class="annottext">y -&gt; [y] -&gt; [y]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[y]
</span><a href="#local-6989586621680778144"><span class="hs-identifier hs-var">xs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>    </span><span class="annot"><a href="#local-6989586621680778155"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680778143"><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778143"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(acc, [y]) -&gt; m (acc, [y])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">acc
</span><a href="#local-6989586621680778143"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-comment">-- | Monadic version of mapSnd</span><span>
</span><span id="line-161"></span><span id="local-6989586621680778354"><span id="local-6989586621680778355"><span id="local-6989586621680778356"><span id="local-6989586621680778357"><span class="annot"><a href="GHC.Utils.Monad.html#mapSndM"><span class="hs-identifier hs-type">mapSndM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778357"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778356"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778357"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778355"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778354"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778356"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778357"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778354"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621680778355"><span class="hs-identifier hs-type">c</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span></span></span></span></span><span>
</span><span id="line-162"></span><span id="mapSndM"><span class="annot"><span class="annottext">mapSndM :: forall (m :: * -&gt; *) b c a.
Monad m =&gt;
(b -&gt; m c) -&gt; [(a, b)] -&gt; m [(a, c)]
</span><a href="GHC.Utils.Monad.html#mapSndM"><span class="hs-identifier hs-var hs-var">mapSndM</span></a></span></span><span> </span><span id="local-6989586621680778141"><span class="annot"><span class="annottext">b -&gt; m c
</span><a href="#local-6989586621680778141"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778140"><span class="annot"><span class="annottext">[(a, b)]
</span><a href="#local-6989586621680778140"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(a, b)] -&gt; m [(a, c)]
forall {a}. [(a, b)] -&gt; m [(a, c)]
</span><a href="#local-6989586621680778139"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(a, b)]
</span><a href="#local-6989586621680778140"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-164"></span><span>    </span><span id="local-6989586621680778139"><span class="annot"><span class="annottext">go :: [(a, b)] -&gt; m [(a, c)]
</span><a href="#local-6989586621680778139"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(a, c)] -&gt; m [(a, c)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-165"></span><span>    </span><span class="annot"><a href="#local-6989586621680778139"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621680778134"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778134"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680778133"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680778133"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778132"><span class="annot"><span class="annottext">[(a, b)]
</span><a href="#local-6989586621680778132"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680778131"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778131"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">b -&gt; m c
</span><a href="#local-6989586621680778141"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680778133"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">;</span><span> </span><span id="local-6989586621680778130"><span class="annot"><span class="annottext">[(a, c)]
</span><a href="#local-6989586621680778130"><span class="hs-identifier hs-var">rs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(a, b)] -&gt; m [(a, c)]
</span><a href="#local-6989586621680778139"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(a, b)]
</span><a href="#local-6989586621680778132"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[(a, c)] -&gt; m [(a, c)]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778134"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778131"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span class="annot"><span class="annottext">(a, c) -&gt; [(a, c)] -&gt; [(a, c)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[(a, c)]
</span><a href="#local-6989586621680778130"><span class="hs-identifier hs-var">rs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span class="hs-comment">-- | Monadic version of concatMap</span><span>
</span><span id="line-168"></span><span id="local-6989586621680778346"><span id="local-6989586621680778347"><span id="local-6989586621680778348"><span class="annot"><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-type">concatMapM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778348"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778347"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778348"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778346"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778347"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778348"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778346"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span></span></span></span><span>
</span><span id="line-169"></span><span id="concatMapM"><span class="annot"><span class="annottext">concatMapM :: forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m [b]) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#concatMapM"><span class="hs-identifier hs-var hs-var">concatMapM</span></a></span></span><span> </span><span id="local-6989586621680778124"><span class="annot"><span class="annottext">a -&gt; m [b]
</span><a href="#local-6989586621680778124"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778123"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778123"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([[b]] -&gt; [b]) -&gt; m [[b]] -&gt; m [b]
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="annot"><span class="annottext">[[b]] -&gt; [b]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; m [b]) -&gt; [a] -&gt; m [[b]]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m [b]
</span><a href="#local-6989586621680778124"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778123"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>
</span><span id="line-171"></span><span class="hs-comment">-- | Applicative version of mapMaybe</span><span>
</span><span id="line-172"></span><span id="local-6989586621680778332"><span id="local-6989586621680778333"><span id="local-6989586621680778334"><span class="annot"><a href="GHC.Utils.Monad.html#mapMaybeM"><span class="hs-identifier hs-type">mapMaybeM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778334"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778333"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778334"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778332"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778333"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778334"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778332"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">]</span></span></span></span><span>
</span><span id="line-173"></span><span id="mapMaybeM"><span class="annot"><span class="annottext">mapMaybeM :: forall (m :: * -&gt; *) a b.
Applicative m =&gt;
(a -&gt; m (Maybe b)) -&gt; [a] -&gt; m [b]
</span><a href="GHC.Utils.Monad.html#mapMaybeM"><span class="hs-identifier hs-var hs-var">mapMaybeM</span></a></span></span><span> </span><span id="local-6989586621680778116"><span class="annot"><span class="annottext">a -&gt; m (Maybe b)
</span><a href="#local-6989586621680778116"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; m [b] -&gt; m [b]) -&gt; m [b] -&gt; [a] -&gt; m [b]
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m [b] -&gt; m [b]
</span><a href="#local-6989586621680778114"><span class="hs-identifier hs-var">g</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[b] -&gt; m [b]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-174"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680778114"><span class="annot"><span class="annottext">g :: a -&gt; m [b] -&gt; m [b]
</span><a href="#local-6989586621680778114"><span class="hs-identifier hs-var hs-var">g</span></a></span></span><span> </span><span id="local-6989586621680778112"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778112"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Maybe b -&gt; [b] -&gt; [b]) -&gt; m (Maybe b) -&gt; m [b] -&gt; m [b]
forall (f :: * -&gt; *) a b c.
Applicative f =&gt;
(a -&gt; b -&gt; c) -&gt; f a -&gt; f b -&gt; f c
</span><a href="../../base/src/GHC.Base.html#liftA2"><span class="hs-identifier hs-var">liftA2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([b] -&gt; [b]) -&gt; (b -&gt; [b] -&gt; [b]) -&gt; Maybe b -&gt; [b] -&gt; [b]
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[b] -&gt; [b]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">:</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; m (Maybe b)
</span><a href="#local-6989586621680778116"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778112"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span class="hs-comment">-- | Monadic version of fmap</span><span>
</span><span id="line-177"></span><span id="local-6989586621680778316"><span id="local-6989586621680778317"><span id="local-6989586621680778318"><span class="annot"><a href="GHC.Utils.Monad.html#fmapMaybeM"><span class="hs-identifier hs-type">fmapMaybeM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778318"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778317"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778318"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778316"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778317"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778318"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778316"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span></span></span><span>
</span><span id="line-178"></span><span id="fmapMaybeM"><span class="annot"><span class="annottext">fmapMaybeM :: forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Maybe a -&gt; m (Maybe b)
</span><a href="GHC.Utils.Monad.html#fmapMaybeM"><span class="hs-identifier hs-var hs-var">fmapMaybeM</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; m (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-179"></span><span class="annot"><a href="GHC.Utils.Monad.html#fmapMaybeM"><span class="hs-identifier hs-var">fmapMaybeM</span></a></span><span> </span><span id="local-6989586621680778104"><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778104"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680778103"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778103"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778104"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778103"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">m b -&gt; (b -&gt; m (Maybe b)) -&gt; m (Maybe b)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe b -&gt; m (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe b -&gt; m (Maybe b)) -&gt; (b -&gt; Maybe b) -&gt; b -&gt; m (Maybe b)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Maybe b
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-180"></span><span>
</span><span id="line-181"></span><span class="hs-comment">-- | Monadic version of fmap</span><span>
</span><span id="line-182"></span><span id="local-6989586621680778303"><span id="local-6989586621680778304"><span id="local-6989586621680778305"><span id="local-6989586621680778306"><span id="local-6989586621680778307"><span class="annot"><a href="GHC.Utils.Monad.html#fmapEitherM"><span class="hs-identifier hs-type">fmapEitherM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778307"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778306"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778307"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778305"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778304"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778307"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778303"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778306"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778304"><span class="hs-identifier hs-type">c</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778307"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778305"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778303"><span class="hs-identifier hs-type">d</span></a></span><span class="hs-special">)</span></span></span></span></span></span><span>
</span><span id="line-183"></span><span id="fmapEitherM"><span class="annot"><span class="annottext">fmapEitherM :: forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; m b) -&gt; (c -&gt; m d) -&gt; Either a c -&gt; m (Either b d)
</span><a href="GHC.Utils.Monad.html#fmapEitherM"><span class="hs-identifier hs-var hs-var">fmapEitherM</span></a></span></span><span> </span><span id="local-6989586621680778096"><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778096"><span class="hs-identifier hs-var">fl</span></a></span></span><span> </span><span class="annot"><span class="annottext">c -&gt; m d
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span>  </span><span id="local-6989586621680778095"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778095"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778096"><span class="hs-identifier hs-var">fl</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778095"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">m b -&gt; (b -&gt; m (Either b d)) -&gt; m (Either b d)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Either b d -&gt; m (Either b d)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either b d -&gt; m (Either b d))
-&gt; (b -&gt; Either b d) -&gt; b -&gt; m (Either b d)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Either b d
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-184"></span><span class="annot"><a href="GHC.Utils.Monad.html#fmapEitherM"><span class="hs-identifier hs-var">fmapEitherM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680778094"><span class="annot"><span class="annottext">c -&gt; m d
</span><a href="#local-6989586621680778094"><span class="hs-identifier hs-var">fr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span id="local-6989586621680778093"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778093"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">c -&gt; m d
</span><a href="#local-6989586621680778094"><span class="hs-identifier hs-var">fr</span></a></span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621680778093"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">m d -&gt; (d -&gt; m (Either b d)) -&gt; m (Either b d)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Either b d -&gt; m (Either b d)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Either b d -&gt; m (Either b d))
-&gt; (d -&gt; Either b d) -&gt; d -&gt; m (Either b d)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">d -&gt; Either b d
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span class="hs-comment">-- | Monadic version of 'any', aborts the computation at the first @True@ value</span><span>
</span><span id="line-187"></span><span id="local-6989586621680778294"><span id="local-6989586621680778295"><span class="annot"><a href="GHC.Utils.Monad.html#anyM"><span class="hs-identifier hs-type">anyM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778295"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778294"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778295"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778294"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778295"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-188"></span><span id="anyM"><span class="annot"><span class="annottext">anyM :: forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m Bool) -&gt; [a] -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#anyM"><span class="hs-identifier hs-var hs-var">anyM</span></a></span></span><span> </span><span id="local-6989586621680778091"><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778091"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778090"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778090"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m Bool
</span><a href="#local-6989586621680778089"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778090"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-189"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-190"></span><span>    </span><span id="local-6989586621680778089"><span class="annot"><span class="annottext">go :: [a] -&gt; m Bool
</span><a href="#local-6989586621680778089"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-191"></span><span>    </span><span class="annot"><a href="#local-6989586621680778089"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778085"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778085"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778084"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778084"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621680778083"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778083"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778091"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778085"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-192"></span><span>                   </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778083"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-193"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m Bool
</span><a href="#local-6989586621680778089"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778084"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-comment">-- | Monad version of 'all', aborts the computation at the first @False@ value</span><span>
</span><span id="line-196"></span><span id="local-6989586621680778081"><span id="local-6989586621680778082"><span class="annot"><a href="GHC.Utils.Monad.html#allM"><span class="hs-identifier hs-type">allM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778082"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778081"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778082"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778081"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778082"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span></span><span>
</span><span id="line-197"></span><span id="allM"><span class="annot"><span class="annottext">allM :: forall (m :: * -&gt; *) a. Monad m =&gt; (a -&gt; m Bool) -&gt; [a] -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#allM"><span class="hs-identifier hs-var hs-var">allM</span></a></span></span><span> </span><span id="local-6989586621680778079"><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778079"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680778078"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778078"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m Bool
</span><a href="#local-6989586621680778077"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778078"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-199"></span><span>    </span><span id="local-6989586621680778077"><span class="annot"><span class="annottext">go :: [a] -&gt; m Bool
</span><a href="#local-6989586621680778077"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-200"></span><span>    </span><span class="annot"><a href="#local-6989586621680778077"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680778073"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778073"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680778072"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778072"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778079"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778073"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">m Bool -&gt; (Bool -&gt; m Bool) -&gt; m Bool
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621680778071"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778071"><span class="hs-identifier hs-var">bv</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778071"><span class="hs-identifier hs-var">bv</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m Bool
</span><a href="#local-6989586621680778077"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621680778072"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="hs-comment">-- | Monadic version of or</span><span>
</span><span id="line-203"></span><span id="local-6989586621680778289"><span class="annot"><a href="GHC.Utils.Monad.html#orM"><span class="hs-identifier hs-type">orM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778289"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778289"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778289"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778289"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-204"></span><span id="orM"><span class="annot"><span class="annottext">orM :: forall (m :: * -&gt; *). Monad m =&gt; m Bool -&gt; m Bool -&gt; m Bool
</span><a href="GHC.Utils.Monad.html#orM"><span class="hs-identifier hs-var hs-var">orM</span></a></span></span><span> </span><span id="local-6989586621680778067"><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778067"><span class="hs-identifier hs-var">m1</span></a></span></span><span> </span><span id="local-6989586621680778066"><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778066"><span class="hs-identifier hs-var">m2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778067"><span class="hs-identifier hs-var">m1</span></a></span><span> </span><span class="annot"><span class="annottext">m Bool -&gt; (Bool -&gt; m Bool) -&gt; m Bool
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680778065"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778065"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778065"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778066"><span class="hs-identifier hs-var">m2</span></a></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span class="hs-comment">-- | Monadic version of foldl that discards its result</span><span>
</span><span id="line-207"></span><span id="local-6989586621680778284"><span id="local-6989586621680778285"><span id="local-6989586621680778286"><span id="local-6989586621680778287"><span class="annot"><a href="GHC.Utils.Monad.html#foldlM_"><span class="hs-identifier hs-type">foldlM_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778287"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#Foldable"><span class="hs-identifier hs-type">Foldable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778286"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778285"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778284"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778287"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778285"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778285"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778286"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778284"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778287"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span></span></span></span><span>
</span><span id="line-208"></span><span id="foldlM_"><span class="annot"><span class="annottext">foldlM_ :: forall (m :: * -&gt; *) (t :: * -&gt; *) a b.
(Monad m, Foldable t) =&gt;
(a -&gt; b -&gt; m a) -&gt; a -&gt; t b -&gt; m ()
</span><a href="GHC.Utils.Monad.html#foldlM_"><span class="hs-identifier hs-var hs-var">foldlM_</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; m a) -&gt; a -&gt; t b -&gt; m ()
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m ()
</span><a href="../../base/src/Control.Monad.html#foldM_"><span class="hs-identifier hs-var">foldM_</span></a></span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- | Monadic version of fmap specialised for Maybe</span><span>
</span><span id="line-211"></span><span id="local-6989586621680778057"><span id="local-6989586621680778058"><span id="local-6989586621680778059"><span class="annot"><a href="GHC.Utils.Monad.html#maybeMapM"><span class="hs-identifier hs-type">maybeMapM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778059"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778058"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778059"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778057"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778058"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778059"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778057"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span></span></span><span>
</span><span id="line-212"></span><span id="maybeMapM"><span class="annot"><span class="annottext">maybeMapM :: forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; Maybe a -&gt; m (Maybe b)
</span><a href="GHC.Utils.Monad.html#maybeMapM"><span class="hs-identifier hs-var hs-var">maybeMapM</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe b -&gt; m (Maybe b)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe b
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-213"></span><span class="annot"><a href="GHC.Utils.Monad.html#maybeMapM"><span class="hs-identifier hs-var">maybeMapM</span></a></span><span> </span><span id="local-6989586621680778053"><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778053"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680778052"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778052"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(b -&gt; Maybe b) -&gt; m b -&gt; m (Maybe b)
forall (m :: * -&gt; *) a1 r. Monad m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM"><span class="hs-identifier hs-var">liftM</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Maybe b
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(m b -&gt; m (Maybe b)) -&gt; m b -&gt; m (Maybe b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; m b
</span><a href="#local-6989586621680778053"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778052"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-214"></span><span>
</span><span id="line-215"></span><span class="hs-comment">-- | Monadic version of @when@, taking the condition in the monad</span><span>
</span><span id="line-216"></span><span id="local-6989586621680778269"><span class="annot"><a href="GHC.Utils.Monad.html#whenM"><span class="hs-identifier hs-type">whenM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778269"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778269"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778269"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778269"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-217"></span><span id="whenM"><span class="annot"><span class="annottext">whenM :: forall (m :: * -&gt; *). Monad m =&gt; m Bool -&gt; m () -&gt; m ()
</span><a href="GHC.Utils.Monad.html#whenM"><span class="hs-identifier hs-var hs-var">whenM</span></a></span></span><span> </span><span id="local-6989586621680778047"><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778047"><span class="hs-identifier hs-var">mb</span></a></span></span><span> </span><span id="local-6989586621680778046"><span class="annot"><span class="annottext">m ()
</span><a href="#local-6989586621680778046"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680778045"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778045"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778047"><span class="hs-identifier hs-var">mb</span></a></span><span>
</span><span id="line-218"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m () -&gt; m ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778045"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">m ()
</span><a href="#local-6989586621680778046"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-219"></span><span>
</span><span id="line-220"></span><span class="hs-comment">-- | Monadic version of @unless@, taking the condition in the monad</span><span>
</span><span id="line-221"></span><span id="local-6989586621680778043"><span class="annot"><a href="GHC.Utils.Monad.html#unlessM"><span class="hs-identifier hs-type">unlessM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778043"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778043"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778043"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778043"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-222"></span><span id="unlessM"><span class="annot"><span class="annottext">unlessM :: forall (m :: * -&gt; *). Monad m =&gt; m Bool -&gt; m () -&gt; m ()
</span><a href="GHC.Utils.Monad.html#unlessM"><span class="hs-identifier hs-var hs-var">unlessM</span></a></span></span><span> </span><span id="local-6989586621680778038"><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778038"><span class="hs-identifier hs-var">condM</span></a></span></span><span> </span><span id="local-6989586621680778037"><span class="annot"><span class="annottext">m ()
</span><a href="#local-6989586621680778037"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621680778036"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778036"><span class="hs-identifier hs-var">cond</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m Bool
</span><a href="#local-6989586621680778038"><span class="hs-identifier hs-var">condM</span></a></span><span>
</span><span id="line-223"></span><span>                       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; m () -&gt; m ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778036"><span class="hs-identifier hs-var">cond</span></a></span><span> </span><span class="annot"><span class="annottext">m ()
</span><a href="#local-6989586621680778037"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-224"></span><span>
</span><span id="line-225"></span><span class="hs-comment">-- | Like 'filterM', only it reverses the sense of the test.</span><span>
</span><span id="line-226"></span><span id="local-6989586621680778264"><span id="local-6989586621680778265"><span class="annot"><a href="GHC.Utils.Monad.html#filterOutM"><span class="hs-identifier hs-type">filterOutM</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680778265"><span class="hs-identifier hs-type">m</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680778264"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778265"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778264"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680778265"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621680778264"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span></span><span>
</span><span id="line-227"></span><span id="filterOutM"><span class="annot"><span class="annottext">filterOutM :: forall (m :: * -&gt; *) a.
Applicative m =&gt;
(a -&gt; m Bool) -&gt; [a] -&gt; m [a]
</span><a href="GHC.Utils.Monad.html#filterOutM"><span class="hs-identifier hs-var hs-var">filterOutM</span></a></span></span><span> </span><span id="local-6989586621680778030"><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778030"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-228"></span><span>  </span><span class="annot"><span class="annottext">(a -&gt; m [a] -&gt; m [a]) -&gt; m [a] -&gt; [a] -&gt; m [a]
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621680778029"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778029"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; [a] -&gt; [a]) -&gt; m Bool -&gt; m [a] -&gt; m [a]
forall (f :: * -&gt; *) a b c.
Applicative f =&gt;
(a -&gt; b -&gt; c) -&gt; f a -&gt; f b -&gt; f c
</span><a href="../../base/src/GHC.Base.html#liftA2"><span class="hs-identifier hs-var">liftA2</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621680778028"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778028"><span class="hs-identifier hs-var">flg</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680778028"><span class="hs-identifier hs-var">flg</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778029"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; m Bool
</span><a href="#local-6989586621680778030"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680778029"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[a] -&gt; m [a]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-229"></span></pre></body></html>